<?php
namespace app\run\model;

use think\Model;
use think\Db;
class Category extends Model{
	public static function index($options){
		$res = Db::name('category')->alias('a')
		->join('image b','a.topic_img_id=b.id')
		->field('a.id,a.name,b.url')
		->where('state',1)
		->paginate(5,false,$options);
		return $res;
	}

	public static function add(array $data){
		$res = Db::name('category')->insert($data);
		return $res;
	}

	public static function find($where){
		$res = Db::name('category')->where($where)->find();
		return $res;
	}

	public static function up(array $data){
		$res = Db::name('category')->update($data);
		return $res;
	}

	public static function pr(){
		$res = Db::name('category')->field('id,name')->select();
		return $res;
	}
}